package org.evan.spring6.iocxml.di;

public class Book {
    private String bName;
    private String author;
    private String others;

    public Book(){
        System.out.println("无参数构造执行了......");
    }
    public Book(String bName, String author) {
        System.out.println("有参数构造执行了......");
        this.bName = bName;
        this.author = author;
    }
//生成set方法

    public void setbName(String bName) {
        this.bName = bName;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setOthers(String others) {
        this.others = others;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bName='" + bName + '\'' +
                ", author='" + author + '\'' +
                ", others='" + others + '\'' +
                '}';
    }

    public static void main(String[] args) {
        //set方法注入
        Book book = new Book();
        book.setbName("java");
        book.setAuthor("尚硅谷");

        //通过构造器注入
        Book book1 = new Book("c++","尚硅谷");
    }
}
